package cm.unit4.theme2;

import cm.commom.TreeNode;

public class MirrorRecursively {
    public TreeNode Mirror (TreeNode pRoot) {
        if(pRoot == null){
            return null;
        }
        // 交换左右子树
        TreeNode tmp = pRoot.left;
        pRoot.left = pRoot.right;
        pRoot.right = tmp;

        // 递归左子树
        Mirror(pRoot.left);

        // 递归右子树
        Mirror(pRoot.right);

        return pRoot;
    }
}
